// Copyright 2012 Google Inc. All Rights Reserved.

package com.google.appengine.syncserver.shared;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;

/**
 * Response sent to the client when the client sends the last change page.
 */
public class WriteUpdatesResponse {

  private static final String MAX_VERSION = "maxVersion";

  public static WriteUpdatesResponse valueOf(String s) {
    WriteUpdatesResponse resp = new WriteUpdatesResponse(Integer.valueOf(s));
    return resp;
  }

  // max update version till which this response accounts for.
  private final long maxVersion;

  /**
   * @param maxVersion max update version till which this response accounts 
   * for.
   */
  @JsonCreator
  public WriteUpdatesResponse(@JsonProperty(MAX_VERSION) long maxVersion) {
    this.maxVersion = maxVersion;
  }

  /**
   * @return the max update version
   */
  @JsonProperty(MAX_VERSION)
  public long getMaxVersion() {
    return maxVersion;
  }

  // TODO(chintanraoh): remove this toString function every where.
  @Override
  public String toString() {
    return String.valueOf(this.maxVersion);
  }
}
